import { _decorator, Node, Sprite } from 'cc';

import { UniformScaleBase } from './UniformScaleBase';

const { ccclass, property, requireComponent } = _decorator;

/**
 * 等比缩放背景图, 保证背景节点能在当前分辨率下等比铺满
 */
@ccclass('UniformScaleBg')
@requireComponent(Sprite)
export class UniformScaleBg extends UniformScaleBase {


    protected doUniformScale() {
        if (!this.active)
            return;
        const sprite = this.getComponent(Sprite);
        if (!sprite || !sprite.spriteFrame)
            return;
        const imgSize = sprite.spriteFrame.originalSize;
        this.scale = this.getScaleMax(imgSize);
    }

}

